//
//  VehicleMaintenanceTabbar.m
//  阿帕
//
//  Created 阿帕 on 2020/1/4.
//  Copyright © 2020 GCY. All rights reserved.
//

#import "VehicleMaintenanceTabbar.h"
#import "VehicleMaintenanceViewController.h"

#import "SGPagingView.h"

@interface VehicleMaintenanceTabbar ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>

@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;

@end

@implementation VehicleMaintenanceTabbar

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.navigationItem.title = @"车辆维修";

    self.view.backgroundColor = BackgroundColor;

    [self setupPageView];
}

- (void)setupPageView {
    
    CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    CGFloat pageTitleViewY = 0;
    if (statusHeight == 20.0) {
        pageTitleViewY = 64;
    } else {
        pageTitleViewY = 88;
    }
    
//    status 0:审批中 1：已同意 2：已拒绝
    NSArray *orderStatusArr = @[@"",@"0",@"1",@"2"];
    NSArray *orderTitleArr = @[@"全部", @"审核中", @"已通过", @"被拒绝"];
    
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.indicatorStyle = SGIndicatorStyleDynamic;
    configure.titleFont = font(15);
    configure.titleColor = Dark_TextColor;
    configure.titleSelectedColor = Theme_ColorValue;
    configure.indicatorColor = Theme_ColorValue;
    configure.indicatorDynamicWidth = 40;
    configure.indicatorHeight = 3.0f;
    configure.showBottomSeparator = NO;
    configure.titleAdditionalWidth = 35;
    configure.badgeColor = [UIColor redColor];
    
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 1, ScreenW, 44) delegate:self titleNames:orderTitleArr configure:configure];
    [self.view addSubview:_pageTitleView];
    
    NSMutableArray *childArr = [[NSMutableArray alloc] init];
    for (int i=0; i<orderTitleArr.count; i++) {
        VehicleMaintenanceViewController *vmvc = [[VehicleMaintenanceViewController alloc] init];
        vmvc.orderStatus = orderStatusArr[i];
        [childArr addObject:vmvc];
    }
    /// pageContentCollectionView
    CGFloat ContentCollectionViewHeight = self.view.frame.size.height - CGRectGetMaxY(_pageTitleView.frame);
    self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), ScreenW, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
    _pageContentCollectionView.delegatePageContentCollectionView = self;
    [self.view addSubview:_pageContentCollectionView];
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
}

- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}



@end
